package com.example.secondhandsysapi.Mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.sql.Date;
import java.util.Map;

@Mapper
public interface ActiveUserInfoMapper {

    @Select("SELECT   \n" +
            "    ui.gender,  \n" +
            "    COUNT(DISTINCT ui.user_id) AS active_user_count  \n" +
            "FROM   \n" +
            "    user_info ui  \n" +
            "JOIN   \n" +
            "    look_log ll ON ui.user_id = ll.user_id  \n" +
            "WHERE   \n" +
            "    ui.role <> '管理员' -- 筛选出非管理员用户  \n" +
            "    AND ll.#{log_time} >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) -- 最近30天内的活跃用户  \n" +
            "GROUP BY   \n" +
            "    ui.gender")
    Map<Integer,Integer> getActiveUserInfo(Date log_time);

}
